<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
    <link type="text/css" rel="stylesheet" href="css/personal.css"/>
    <script type="text/javascript" src="js/jquery-1.12.4.min.js"></script>
    <script type="text/javascript" src="https://code.jquery.com/jquery-3.1.1.min.js"></script>
    <script type="text/javascript" src="js/personal.js"></script>
    <script type="text/javascript">
        var nowpage = 1;
        var keyword = "";
        var uid = "${user.uid}"

        function diffTime(endDate, startDate) {
            var startDate = new Date(startDate);
            var endDate = new Date(endDate);
            var nd = 1000 * 24 * 60 * 60;
            var nh = 1000 * 60 * 60;
            var nm = 1000 * 60;
            // long ns = 1000;
            // 获得两个时间的毫秒时间差异
            var diff = endDate.getTime() - startDate.getTime();
            // 计算差多少天
            var day = diff / nd;
            // 计算差多少小时
            var hour = diff % nd / nh;
            // 计算差多少分钟
            var min = diff % nd % nh / nm;
            // 计算差多少秒//输出结果
            // long sec = diff % nd % nh % nm / ns;
            if (day >= 1) {
                return day + "天";
            } else if (hour >= 1 && day < 1) {
                return hour + "小时";
            } else {
                return min + "分钟";
            }
        }

        function initpagesearch(PageHelper) {
            $("tbody").empty()
            $("[id='PageBlock']").empty()
            eval("var PageHelper=" + PageHelper);
            for (var i = 0; i < PageHelper.userJobEnterpriseDaoList.length; i++) {
                var jrefreshdate = PageHelper.userJobEnterpriseDaoList[i].job.jrefreshdate;
                var jreleasedate = PageHelper.userJobEnterpriseDaoList[i].job.jreleasedate;
                var difTime = diffTime(jrefreshdate, jreleasedate);
                var obj =
                    "<tr>" +
                    "<td>" +
                    "<a href='getOnejobByJid.do?uid=" + uid + "&jid=" + PageHelper.userJobEnterpriseDaoList[i].job.jid + "' class='jobname'>" + PageHelper.userJobEnterpriseDaoList[i].job.jname + "</a>" +
                    "</td>" +
                    "<td>" +
                    "<div class='company'>" +
                    "<a href='company.do?eid=" + PageHelper.userJobEnterpriseDaoList[i].job.enterprise.eid + "'>" + PageHelper.userJobEnterpriseDaoList[i].job.enterprise.ename + "</a>" +
                    "</div>" +
                    "</td>" +
                    "<td></td>" +
                    "<td>" + PageHelper.userJobEnterpriseDaoList[i].job.jplace + "</td>" +
                    "<td><span>" + PageHelper.userJobEnterpriseDaoList[i].job.jmonthsalary + "</span></td>" +
                    "<td>" + difTime + "</td>" +
                    "</tr>" +
                    "<tr class='xxdetail none'>" +
                    "<td colspan='5'>" +
                    "<div class='yaoqiu'>学历要求：" + PageHelper.userJobEnterpriseDaoList[i].job.jmineducation +
                    " | 工作经验：" + PageHelper.userJobEnterpriseDaoList[i].job.jexperience +
                    "| 公司规模：" + PageHelper.userJobEnterpriseDaoList[i].job.jrecruitsbumber +
                    "人 | 招聘方式：" + PageHelper.userJobEnterpriseDaoList[i].job.jrecruitmentmethod +
                    "<br/>" +
                    "岗位职责：" + PageHelper.userJobEnterpriseDaoList[i].job.jresponsibility + "<br/>" +
                    "岗位要求：" + PageHelper.userJobEnterpriseDaoList[i].job.jrequirements +
                    "</div></td><td>";
                if (PageHelper.userJobEnterpriseDaoList[i].jobuserstatus == 1) {
                    obj = obj + "<div id='ApplyDiv' class='applydiv' >" +
                        "<a id='Applya' class='ysqbtn'  href='getOnejobByJid.do?uid=" + uid + "&jid=" + PageHelper.userJobEnterpriseDaoList[i].job.jid + "' >已申请</a>";
                } else {
                    obj = obj + "<div id='ApplyDiv' class='applydiv' >" +
                        "<a id='Applya' class='ljsqbtn'  href='getOnejobByJid.do?uid=" + uid + "&jid=" + PageHelper.userJobEnterpriseDaoList[i].job.jid + "'>立即申请</a>"
                }
                if (PageHelper.userJobEnterpriseDaoList[i].jobuserattention == 1) {
                    obj = obj + "<span id='jobattentionspan" + PageHelper.userJobEnterpriseDaoList[i].job.jid + "' valus='" + PageHelper.userJobEnterpriseDaoList[i].job.jid + "' class='ygz'>已关注</span>";
                } else {
                    obj = obj + "<span id='jobattentionspan" + PageHelper.userJobEnterpriseDaoList[i].job.jid + "' valus='" + PageHelper.userJobEnterpriseDaoList[i].job.jid + "' >关注</span>";
                }
                $(obj).appendTo("tbody")
            }
            $("#headiv").empty()
            $("#footdiv").empty()
            var pagetip = "<span>共" + PageHelper.countnums + "条  第" + PageHelper.nowpage + "/" + PageHelper.countpage + "页</span>"
            $(pagetip).appendTo($("#headiv"))
            $(pagetip).appendTo($("#footdiv"))
            var PageNumber =
                "<a id='HomePage' value='1' class='fy1'>首页</a>" +
                "<a id='PreviousPage'  class='fy1'>上一页</a>";
            for (var i = 1; i <= PageHelper.countpage; i++) {
                if (i == PageHelper.nowpage) {
                    PageNumber = PageNumber + "<a id='page'  class='fy2 on'>" + i + "</></a>"
                } else {
                    PageNumber = PageNumber + "<a id='page' class='fy2'>" + i + "</a>"
                }
            }
            PageNumber = PageNumber +
                "<a id='NextPage'  class='fy1' >下一页</a>" +
                "<a id='LastPage' value='" + PageHelper.countpage + "' class='fy1'>尾页</a>";
            $(PageNumber).appendTo($("[id='PageBlock']"))
        }

        function pagesearch() {
            $.get("getjobsByUidPageHelper.do",
                "uid=${user.uid}" +
                "&keyword=" + keyword +
                "&nowpage=" + nowpage, function (PageHelper) {
                    initpagesearch(PageHelper)
                })
        }

        $(document).ready(function () {
            if ("${user.uid}" != "") {
                pagesearch();
            } else {
                window.location.replace("login.jsp")
            }
            // 页码点击事件
            $(document).on("click", "[id='page']", function () {
                nowpage = $(this).html()
                pagesearch()
            });
            //搜索选项点击事件
            $("#searchkword").click(function () {
                nowpage = 1;
                if ($("[id='keyword']").val() != "") {
                    keyword = $("[id='keyword']").val();
                } else {
                    keyword = ""
                }
                pagesearch()
            });
            //首页点击事件
            $(document).on("click", "[id='HomePage']", function () {
                nowpage = $("[id='HomePage']").attr("value")
                pagesearch()
            });
            //上一页点击事件
            $(document).on("click", "[id='PreviousPage']", function () {
                if (nowpage > 1) {
                    nowpage = nowpage - 1;
                    pagesearch()
                } else {
                    pagesearch()
                }
            });
            //尾页点击事件
            $(document).on("click", "[id='LastPage']", function () {
                nowpage = $("[id='LastPage']").attr("value")
                pagesearch()
            });
            //下一页点击事件
            $(document).on("click", "[id='NextPage']", function () {
                if (nowpage < $("[id='LastPage']").attr("value")) {
                    nowpage = nowpage + 1;
                    pagesearch()
                }
            });

            $(document).on("click", "span", function () {
                var spanid = $(this).attr("id")
                var jid = $(this).attr("valus");
                if (jid != undefined) {
                    if ("${user.uid}" != "") {
                        $.get("queryUserJobEnterprise.do",
                            {
                                "uid": "${user.uid}",
                                "eid": "${userJobEnterprise.job.enterprise.eid}",
                                "jid": jid
                            },
                            function (obj) {
                                eval("var str=" + obj)
                                if (str == null) {
                                    $.get("addUserJobEnterprisewithUser.do",
                                        {
                                            "uid": "${user.uid}",
                                            "eid": "${userJobEnterprise.job.enterprise.eid}",
                                            "jid": jid,
                                            "jobuserattention": 1
                                        }, function (i) {
                                            if (i == 1) {
                                                $("[id='" + spanid + "']").html("已关注")
                                                $("[id='" + spanid + "']").attr("class", "ygz")

                                            }
                                        })
                                } else {
                                    if (str.jobuserattention == null || str.jobuserattention == 0) {
                                        $.get("modifyUserJobEnterprise.do",
                                            {
                                                "uid": "${user.uid}",
                                                "eid": "${userJobEnterprise.job.enterprise.eid}",
                                                "jid": jid,
                                                "jobuserattention": 1
                                            },
                                            function (i) {
                                                if (i == 1) {
                                                    $("[id='" + spanid + "']").html("已关注")
                                                    $("[id='" + spanid + "']").attr("class", "ygz")

                                                }

                                            });
                                    } else if (str.jobuserattention == 1) {
                                        $.get("modifyUserJobEnterprise.do",
                                            {
                                                "uid": "${user.uid}",
                                                "eid": "${userJobEnterprise.job.enterprise.eid}",
                                                "jid": jid,
                                                "jobuserattention": 0
                                            },
                                            function (i) {
                                                if (i == 1) {
                                                    $("[id='" + spanid + "']").html("关注")
                                                    $("[id='" + spanid + "']").removeClass("ygz")

                                                }
                                            })
                                    }
                                }
                            })
                    } else {
                        window.location.replace("index.jsp")
                    }
                }

            })
        })
    </script>
    <title>个人中心-我的职位</title>
</head>

<body>
<div class="header">
    <div class="headerMain">
        <div class="Notice">
        </div>
        <div class="Account">
            <div class="Left">
                <div class="Info">
                    <font>[28421947]</font>
                    <input type="button">
                    <div id="InfoPopup">
                        <ul>
                            <li><a href="exit.do">退出</a></li>
                        </ul>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>
<div class="navTop">
    <div class="navTopmain">
        <div class="logo"><a href="index.jsp"><img src="images/logo_1.png"/><img src="images/logo_2.png"/></a></div>
        <div class="nav">
        </div>
    </div>
</div>
<div class="personalBody">
    <div class="perRightcon">
        <div class="commonTit">
            <h1 class="fl">职位搜索</h1>
        </div>
        <div class="clear"></div>
        <div class="zwssPart1">
            <div class="zxssPart1_1">
                <input name="" type="text" placeholder="请填写关键词或选择职位" value="" id="keyword"/>
            </div>
            <div class="zxssPart1_4">
                <input id="searchkword" name="" type="button" value="搜工作"/>
            </div>
        </div>
        <div class="clear"></div>
        <div class="zwssPart3">
            <div class="seachlist">
                <div class="listtop">
                    <div class="tj1">
                        <span class="list on">列表</span>
                        <span class="zhaoyao">摘要</span>
                    </div>
                    <div id="headiv" class="tj3">
                        <span>共1141条  第1/39页</span>
                    </div>
                </div>
                <div class="clear"></div>
                <div class="listcon">
                    <table border="0" width="100%" cellpadding="0" cellspacing="0" class="listtab">
                        <thead>
                        <tr>
                            <th width="24%" style="padding-left:17px">职位名称</th>
                            <th width="30%">企业名称</th>
                            <th width="9%"></th>
                            <th width="16%">工作地点</th>
                            <th width="8%">薪水</th>
                            <th width="9%">刷新时间</th>
                        </tr>
                        </thead>
                        <tbody>
                        <%--<tr>
                            <td>
                                <a href="job_info.jsp" class="jobname">后勤文员</a>
                            </td>
                            <td>
                                <div class="company">
                                    <a href="company.jsp">河北同源科技发展有限公司</a>
                                </div>
                            </td>
                            <td></td>
                            <td>河北佛山南海区</td>
                            <td><span>2.5K-3.5K</span></td>
                            <td>1小时</td>
                        </tr>
                        <tr class="xxdetail none">
                            <td colspan="5">
                                <div class="yaoqiu">学历要求：中专 | 工作经验：1~2年 | 公司规模：少于50人 | 招聘方式：全职<br/>
                                    岗位职责：1、 负责公司资产管理、办公用品采购及劳保用品的管理工作,避免公司资产流失和浪费； 2、 负责书刊资料印刷、快递、物流及办公室的其他事情； 3、
                                    ...<br/>
                                    岗位要求：1、1年以上行政工作经验； 2、熟悉行政工作流程，办公用品采购流程，企业资产管理； 3、较强的责任心和敬业精神，良好的组织协调能力及沟通能力，较...
                                </div>
                            </td>
                            <td>
                                <div class="applydiv">
                                    <a href="javascript:void(0);" class="ysqbtn">已申请</a>
                                    <span class="ygz">已关注</span>
                                </div>
                            </td>
                        </tr>
                        <tr style="background: rgb(247, 248, 250)">
                            <td>
                                <a href="job_info.jsp" class="jobname">国际贸易专员</a>
                            </td>
                            <td>
                                <div class="company">
                                    <a href="company.jsp">深圳市鼎润轻纺进出口有限公司</a>
                                </div>
                            </td>
                            <td></td>
                            <td>河北深圳福田区</td>
                            <td>3.5K-6K</td>
                            <td>刚刚</td>
                        </tr>
                        <tr style="background: rgb(247, 248, 250)" class="xxdetail none">
                            <td colspan="5">
                                <div class="yaoqiu">学历要求：中专 | 工作经验：1~2年 | 公司规模：少于50人 | 招聘方式：全职<br/>
                                    岗位职责：1、 负责公司资产管理、办公用品采购及劳保用品的管理工作,避免公司资产流失和浪费； 2、 负责书刊资料印刷、快递、物流及办公室的其他事情； 3、
                                    ...<br/>
                                    岗位要求：1、1年以上行政工作经验； 2、熟悉行政工作流程，办公用品采购流程，企业资产管理； 3、较强的责任心和敬业精神，良好的组织协调能力及沟通能力，较...
                                </div>
                            </td>
                            <td>
                                <div class="applydiv">
                                    <a href="javascript:void(0);" class="ysqbtn">已申请</a>
                                    <span>关注</span>
                                </div>
                            </td>
                        </tr>--%>
                        </tbody>
                    </table>
                </div>
                <div class="clear"></div>
                <div class="listbottom">
                    <div id="footdiv" class="lb3"><span>共1141条  第1/39页</span></div>
                </div>
                <div class="clear"></div>
                <div class="fenyediv" id="PageBlock">
                    <<%--a href="javascript:void(0)" class="fy1">首页</a>
                    <a href="javascript:void(0)" class="fy1">上一页</a>
                    <a href="javascript:void(0)" class="fy2 on">1</a>
                    <a href="javascript:void(0)" class="fy2">2</a>
                    <a href="javascript:void(0)" class="fy2">3</a>
                    <a href="javascript:void(0)" class="fy2">4</a>
                    <a href="javascript:void(0)" class="fy2">5</a>
                    <a href="javascript:void(0)" class="fy2">6</a>
                    <a href="javascript:void(0)" class="fy2">7</a>
                    <a href="javascript:void(0)" class="fy2">8</a>
                    <a href="javascript:void(0)" class="fy2">9</a>
                    <a href="javascript:void(0)" class="fy2">10</a>
                    <a href="javascript:void(0)" class="fy1">下一页</a>
                    <a href="javascript:void(0)" class="fy1">尾页</a>--%>
                </div>
                <div class="clear"></div>
            </div>
        </div>
    </div>
</div>


<div class="clear"></div>
<div class="footer">
</div>
</body>
</html>
